
const idSymbol = Symbol('this is identifier');
console.log( idSymbol, typeof idSymbol );

const nameSymbol = Symbol('this is name');
console.log( nameSymbol, typeof nameSymbol );

const genderPropertyName = '性别';

// 在"对象字面量"中允许用变量做属性名，只不过变量要用[]包起来
const person = {
    [idSymbol]: 1001,
    [nameSymbol]: '李小芳',
    [genderPropertyName]: '靓妹儿'
}

/* 以上根据"对象字面量"完成的操作相当于以下操作
const person = new Object();
person[idSymbol] = 1001;
person[nameSymbol] = '李小芳';
person[genderPropertyName] = '靓妹儿';
*/

console.log( person );

console.log( person[idSymbol] );
console.log( person[nameSymbol] );
console.log( person[genderPropertyName] );

let names = Object.getOwnPropertyNames( person );
console.log( names );

// Object.getOwnPropertySymbols( object )
// 作用: 获取指定对象(object)自身的所有Symbol属性的组成的数组
// 返回: 返回指定对象自身所有Symbol属性组成的数组
let symbols = Object.getOwnPropertySymbols(person);
console.log( symbols );